export default {
	namespaced: true,
	// 数据
	state: {
		token: uni.getStorageSync("token") || '',
		userInfo: JSON.parse(uni.getStorageSync('userInfo') || `{"data":{
"code":null,
"data":
{
"avatar":null,
"createTime":null,
"id":null,
"idNumber":null,
"name":null,
"openid":null,
"phone":null,
"sex":null
},
"msg":null
}}`), //用户信息对象
		userId: uni.getStorageSync("userId") || ''
	},
	mutations: {
		// updateUserInfo(state,userInfo){
		//  state.userInfo=userInfo
		//  this.commit('m_user/saveUserInfoToStorage')
		// },


		//更新token
		updateToken(state, token) {
			state.token = token
			this.commit('m_user/saveTokenToStroage')
		},
		//存储token
		saveTokenToStroage(state) {
			uni.setStorageSync('token', state.token)
		},
		//更新用户信息
		updateUserInfo(state, userInfo) {
			state.userInfo = userInfo
			this.commit('m_user/saveUserInfoToStorage')
		},
		//保存用户信息
		saveUserInfoToStorage(state) {
			uni.setStorageSync('userInfo', JSON.stringify(state.userInfo))
		},
		//更新用户id
		updateUserId(state, userId) {
			state.userId = userId
			this.commit('m_user/saveUserIdToStroage')
		},
		//存储用户id
		saveUserIdToStroage(state) {
			uni.setStorageSync('userId', state.userId)
		}
	},
	getters: {

	}
}